
<template>
<div class="container">
  <div id="myChart" :style="{width:'100%',height: '200px'}"></div>
</div>
</template>
<script>
require('echarts-wordcloud');
export default {
  name: 'hello',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  },
  mounted () {
    this.drawLine()
  },
  methods: {
    createRandomItemStyle () {
      return {
        normal: {
          color: 'rgb(' + [
            Math.round(Math.random() * 160),
            Math.round(Math.random() * 160),
            Math.round(Math.random() * 160)
          ].join(',') + ')'
        }
      }
    },
    drawLine () {
      // 基于准备好的dom，初始化echarts实例
      let myChart = this.$echarts.init(document.getElementById('myChart'))
      // 绘制图表
      let option = {
        series: [{
          name: 'Google Trends',
          type: 'wordCloud',
          size: ['100%', '100%'],
          textRotation: [0, 45, 90, -45],
          rotationRange: [-90, 90],
          textPadding: 0,
          autoSize: {
            enable: true,
            minSize: 30
          },
          data: [
            {
              name: 'Sam S Club',
              value: 10000,
              itemStyle: {
                normal: {
                  color: 'black'
                }
              }
            },
            {
              name: '云词占位云词占位',
              value: 1,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Amy 云词占位云词占位',
              value: 2,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Jurassic 云词占位云词占位',
              value: 3,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Charter 云词占位云词占位',
              value: 2467,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: '云词占位云词占位 Fil A',
              value: 2244,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Planet 云词占位云词占位',
              value: 1898,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: '云词占位云词占位 Perfect',
              value: 1484,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Express',
              value: 1112,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Home',
              value: 965,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Johnny Depp',
              value: 847,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Lena云词占位云词占位 Dunham',
              value: 582,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Lewis Ha云词占位云词占位milton',
              value: 555,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'KXA云词占位云词占位N',
              value: 550,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Mar云词占位云词占位y Ellen Mark',
              value: 462,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Far云词占位云词占位rah Abraham',
              value: 366,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Rit云词占位云词占位a Ora',
              value: 360,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Ser云词占位云词占位ena Williams',
              value: 282,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'NCAA bas云词占位云词占位eball tournament',
              value: 273,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Point Br云词占位云词占位eak',
              value: 265,
              itemStyle: this.createRandomItemStyle()
            },{
              name: 'Mac云词占位云词占位ys',
              value: 6181,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Am云词占位云词占位y Schumer',
              value: 4386,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Juras云词占位云词占位sic World',
              value: 4055,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Chart云词占位云词占位er Communications',
              value: 2467,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Chi云词占位云词占位ck Fil A',
              value: 2244,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Pla云词占位云词占位net Fitness',
              value: 1898,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Pit云词占位云词占位ch Perfect',
              value: 1484,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Expre云词占位云词占位ss',
              value: 1112,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Hom云词占位云词占位e',
              value: 965,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Johnny De云词占位云词占位pp',
              value: 847,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Len云词占位云词占位a Dunham',
              value: 582,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Lew云词占位云词占位is Hamilton',
              value: 555,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'KXA云词占位云词占位N',
              value: 550,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Mar y Ellen Mark',
              value: 462,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Farrah Abraham',
              value: 366,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Rita Ora',
              value: 360,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Serena Williams',
              value: 282,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'NCAA baseball tournament',
              value: 273,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Point Break',
              value: 265,
              itemStyle: this.createRandomItemStyle()
            },{
              name: 'Macys',
              value: 6181,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Amy Schumer',
              value: 4386,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Jurassic World',
              value: 4055,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: '云词占位云词占位云词占位云词占位云词占位云词占位云词占位云词占位云词占位云词占位云词占位云词占位云词占位',
              value: 12467,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Chick Fil A',
              value: 2244,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Planet Fitness',
              value: 1898,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Pitch Perfect',
              value: 1484,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Express',
              value: 1112,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Home',
              value: 965,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Johnny Depp',
              value: 847,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Lena Dunham',
              value: 582,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Lewis Hamilton',
              value: 555,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'KXAN',
              value: 550,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Mary Ellen Mark',
              value: 462,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Farrah Abraham',
              value: 366,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Rita Ora',
              value: 360,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Serena Williams',
              value: 282,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'NCAA baseball tournament',
              value: 273,
              itemStyle: this.createRandomItemStyle()
            },
            {
              name: 'Point Break',
              value: 265,
              itemStyle: this.createRandomItemStyle()
            }
          ]
        }]
      }
 
      // 为echarts对象加载数据
      myChart.setOption(option)
    }
  }
}
</script>
<style>
 
</style>